package  datastruct;
 
import  java.util.LinkedHashMap;
import  java.util.Map;
 
public  class  LRUCache  extends  LinkedHashMap
{
	private  static  final  long  serialVersionUID = 1L;
	protected  int  maxElements;
 
     public  LRUCache( int  maxSize)
     {
         super (maxSize,  0.75F,  true );
         maxElements = maxSize;
     }
 
     protected  boolean  removeEldestEntry(java.util.Map.Entry eldest)
     {
         return  size() > maxElements;
     }
 
     public static void main(String[] args) {
    	 LRUCache lruCache =new LRUCache(10);
    	 lruCache.put("1", "1");
    	 lruCache.put("2", "1");
    	 lruCache.put("3", "1");
    	 lruCache.put("4", "1");
    	 lruCache.put("5", "1");
    	 lruCache.put("6", "1");
    	 lruCache.put("7", "1");
    	 lruCache.put("8", "1");
    	 lruCache.put("9", "1");
    	 lruCache.put("10", "1");
    	 lruCache.put("11", "1");
    	 lruCache.put("12", "1");
    	 
    	lruCache.forEach((x,y)->System.out.println(x+":"+y));
    	 
	}
     
}